package com.briup.jz.web.controller;

import com.briup.jz.bean.OrderLine;
import com.briup.jz.bean.extend.OrderLineExtend;
import com.briup.jz.service.IOrderLineService;
import com.briup.jz.utils.Message;
import com.briup.jz.utils.MessageUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @program: jz
 * @description: 订单列表控制器
 * @author: catmilko
 * @create: 2020/6/12 15:51
 **/

@RestController
@RequestMapping("/orderLine")
@Api(description = "订单项管理接口")
public class OrderLineController {
    @Autowired
    private IOrderLineService orderLineService;

    @GetMapping("findAll")
    @ApiOperation("查询所有订单列表信息")
    public Message findAll(){
        List<OrderLine> list = orderLineService.findAll();
        return MessageUtil.success(list);
    }
    @PostMapping("saveOrUpdate")
    @ApiOperation(value = "保存或通过id更新订单列表信息")
    public Message saveOrUpdate(OrderLine orderLine){
        orderLineService.saveOrUpdate(orderLine);
        return MessageUtil.success("保存或更新成功");
    }

    @GetMapping("deleteById")
    @ApiOperation("通过id删除订单列表信息")
    public Message deleteById(long id){
        orderLineService.deleteById(id);
        return MessageUtil.success("删除成功");
    }

    @GetMapping("findAllAboutProduct")
    @ApiOperation("查出订单产品的详细信息")
    public Message findAllAboutProduct(){
        List<OrderLineExtend> list = orderLineService.findAllAboutProduct();
        return MessageUtil.success(list);
    }

}
